<%@page import="dao.BookDao"%>
<%@page import="entity.Book"%>
<%@page import="entity.Address"%>
<%@page import="dao.AddressDao"%>
<%@page import="entity.OrderInfo"%>
<%@page import="dao.OrderDao"%>
<%@page import="entity.OrderForm"%>
<%@page import="java.util.List"%>
<%@page import="java.util.List"%>
<%@page import="entity.Member"%>
<%@page import="dao.MemberDao"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" charset="utf-8" />
        <title>JSP Page</title>
        <script type="text/javascript">
            function check(){
                if(document.ff.bookname.value==""){
                    alert("请输入图书信息！");
                    return false;
                }
                return true;
            }
        </script>
    </head>
    <body>
        <div style="margin-left: 10px" >
                <div style="position: absolute;width:300px">
                    <h1 class="text-success">您好，<%=request.getParameter("name")%> </h1>
                    <h3><a href="Collection.jsp?name=<%=request.getParameter("name")%>">查看收藏夹</a></h3>
                    <h3><a href="Cart.jsp">查看购物车</a></h3>
                    <h3><a href="Deposit.jsp">账号充值</a></h3>
                    <h3><a href="Address.jsp">管理收货地址</a></h3>
                </div>

                    <div style="position:absolute;left:1300px;top:10px">
                        <h3><a href="index" class="btn btn-sm btn-warning text-center">返回首页</a></h3>
                    </div>
                    <div style="position:absolute;left:400px">
                        <h1 class="text-primary text-center">订单列表</h1>
                        <br>
                        
                        <form name="ff"   action="gobbn" onsubmit="return check()">
            <div class="col-lg-6" style="width:500px">
                <div class="input-group">
                    <input type="text" class="form-control" name="bookname" >
                    <span class="input-group-btn">
                        <button class="btn btn-default">搜索</button>
                    </span>
                </div>
            </div>
        </form>
                        
                        <div style="position:absolute;top:80px;right:200px"><a href="gobbn?bookname=">查看订单列表</a></div>
                        
                        
                        <br><br><br>
                        &nbsp;&nbsp;查看最近<a href="gos?type=1">一周</a>/<a href="gos?type=2">一个月</a>/<a href="gos?type=3">半年</a>订单<br>
                        &nbsp;&nbsp;查看<a href="gos?type=4">已收货</a>/<a href="gos?type=5">未收货</a>订单<br>
                        &nbsp;&nbsp;查看<a href="gos?type=6">已评价</a>/<a href="gos?type=7">未评价</a>订单<br>
                        <br>
                        <table class="table table-condensed table-striped" style="width: 900px">
                            <tr>
                                <th>订单号</th><th>订单时间</th><th>地址</th><th>收件人</th>
                                <th>书名</th><th>件数</th><th></th>
                            </tr>
                            <%
                                    String name=(String)session.getAttribute("username");
                                    Member member=new MemberDao().getMemberByName(name);

                                    List<OrderForm> orderformList=new OrderDao().getAllOrderForm(member.getId());
                                    for(int j=orderformList.size()-1;j>=0&&j>=orderformList.size()-10;j--){
                                    
                                        List<OrderInfo> orderinfoList=new OrderDao().getOrderInfo(orderformList.get(j).getId());
                                        Address address=new AddressDao().getAddressById(orderformList.get(j).getAddressId());
                            %>
                                <tr>
                                    <td><%=orderformList.get(j).getId()%></td><td><%=orderformList.get(j).getOrderDate()%></td>
                                    <td><%=address.getAddress()%></td><td><%=address.getAddressee()%></td>
                                    <td><ul style="list-style: none">
                                <%
                                        for(int i=0;i<orderinfoList.size();i++){
                                            Book book=new BookDao().getBookById(orderinfoList.get(i).getBookId());                                   
                                %>
                                                    <li><%=book.getBookName()%></li>                            
                                <%
                                        }
                                %>
                                        </ul></td>
                                        <td><ul style="list-style: none">
                                 <%
                                                for(int i=0;i<orderinfoList.size();i++){
                                                        Book book=new BookDao().getBookById(orderinfoList.get(i).getBookId());
                                 %>
                                            <li><%=orderinfoList.get(i).getCount()%></li>
                                 <%
                                        }
                                 %>
                                        </ul></td><td><a href="OrderInfo.jsp?orderid=<%=orderformList.get(j).getId()%>" target="_blank">查看详情</a></td>
                                  <%
                                         }
                                   %>
                        </table>
                    </div>
        </div>
    </body>
</html>
